package com.example.basic.controller;

import com.example.basic.Result.Result;
import com.example.basic.entity.User;
import com.example.basic.service.UserService;
import com.example.basic.utils.JwtUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * ClassName: UserController
 * Description:
 * date: 2021/12/14 9:41
 * author zesion lee
 */

@RequestMapping("/user")
@RestController
@Api(tags = "用户模块")
public class UserController {

    @Resource
    UserService userService;


    @GetMapping("/info/{id}")
    @ApiOperation(value = "根据用户id获取用户信息")
    public Result getUserInfoById(@PathVariable Integer id) {
        User user = userService.getUserInfoById(id);
        return Result.success(user);
    }

    @GetMapping("/login")
    @ApiOperation(value = "登录")
    public Result login() {
        String token = JwtUtil.createToken(1);
        return Result.success(token);
    }


}
